﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ISIM
{
    public partial class IncommingCallDialog : Form
    {
        private string callId;
        private ISIMContact contact;
        private SkypeKit.SktConversation conversation;

        public IncommingCallDialog(ISIMContact contact)
        {
            InitializeComponent();

            this.ControlBox = false;

            this.contact = contact;
            this.conversation = (contact.contactObject as SkypeContact.ContactObject).conversation;

            Bitmap startCallIcon = new Bitmap(Global.appRunPath + "graphics" + System.IO.Path.DirectorySeparatorChar + "startCallIcon.png");
            Bitmap dropCallIcon = new Bitmap(Global.appRunPath + "graphics" + System.IO.Path.DirectorySeparatorChar + "dropCallIcon.png");

            answerCallBut.Text = "";
            answerCallBut.Image = startCallIcon;

            declineCallBut.Text = "";
            declineCallBut.Image = dropCallIcon;

            this.Text = Global.Converter.GetRenamedContactName(contact);

            this.callId = conversation.P_IDENTITY;


            Global.ISIMFunctions.PlaySound(Global.ISIMFunctions.Sounds.incommingCall, true);
        }

        private void answerCallBut_Click(object sender, EventArgs e)
        {
            Global.ISIMFunctions.AnswerCall(contact);

            this.Close();
        }


        private void declineCallBut_Click(object sender, EventArgs e)
        {
            Global.ISIMFunctions.EndCall(contact);

            this.Close();
        }


        private void IncommingCallDialog_Load(object sender, EventArgs e)
        {
            Global.OpenForms.incommingCallDialogList.Add(callId, this);
        }

        private void IncommingCallDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            Global.ISIMFunctions.StopSound();
            Global.OpenForms.incommingCallDialogList.Remove(callId);
        }
    }
}
